<%--
  Created by IntelliJ IDEA.
  User: 86132
  Date: 2023/10/7
  Time: 17:27
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
    <%--引入vue的js--%>
    <script src="../../js/vue.js"></script>
    <!-- 引入组件库 -->
    <script src="../../js/index.js"></script>
    <!--引入axios的依赖-->
    <script src="https://unpkg.com/axios/dist/axios.min.js"></script>
    <!-- import CSS -->
    <link rel="stylesheet" href="../../css/index.css">
</head>
<body>
商品信息总览
<br><br>
<div id="app">
    <el-tabs v-model="activeName">
        <el-tab-pane label="键盘颜色" name="first">
            <el-form :inline="true" :model="formInline" class="demo-form-inline">
                <el-form-item label="">
                    <el-input v-model="formInline.keyboardcolorid" placeholder="请输入ID搜索"></el-input>
                </el-form-item>
                <el-form-item label="">
                    <el-input v-model="formInline.keyboardcolorname" placeholder="请输入键盘颜色搜索"></el-input>
                </el-form-item>
                <el-form-item>
                    <el-button type="primary" @click="searchkeyboard(1)">搜索</el-button>
                </el-form-item>
            </el-form>
            <el-button type="success" @click="addkeyboardcolor" size="small">新增</el-button>
            <template>
                <el-table
                        :data="tableDate1"
                        style="width: 100%">
                    <el-table-column
                            prop="keyboardcolorid"
                            label="ID"
                    >
                    </el-table-column>
                    <el-table-column
                            prop="keyboardcolorname"
                            label="键盘颜色"
                    >
                    </el-table-column>
                    <el-table-column
                            fixed="right"
                            label="操作"
                    >
                        <template slot-scope="scope">
                            <el-button type="primary" @click="updateKeyboardcolor(scope.row)">编辑</el-button>
                            <el-button type="danger" @click="deleteKeyboardcolor(scope.row.keyboardcolorid)">删除
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
            </template>
            <el-pagination
                    @size-change="handleSizeChange"
                    @current-change="handleCurrentChange"
                    :current-page="currentPage"
                    :page-sizes="[1, 5, 10, 15]"
                    :page-size=pageSize
                    layout="total, sizes, prev, pager, next, jumper"
                    :total="total">
            </el-pagination>
        </el-tab-pane>
        <%--            键盘颜色新增的对话框--%>
        <el-dialog
                title="新增键盘颜色"
                :visible.sync="dialogVisible"
                width="30%"
                :before-close="handleClose">
            <el-form ref="form" :model="form" label-width="80px">
                <el-form-item label="键盘颜色">
                    <el-input v-model="form.keyboardcolorname" placeholder="请输入键盘颜色"></el-input>
                </el-form-item>
                <el-button type="primary" @click="onSubmit">立即创建</el-button>
                <el-button @click="dialogVisible=false">取消</el-button>
            </el-form>
            <span slot="footer" class="dialog-footer">
  </span>
        </el-dialog>
        <%--            键盘颜色修改的对话框--%>
        <el-dialog
                title="修改键盘颜色"
                :visible.sync="dialogVisible1"
                width="30%"
                :before-close="handleClose1">
            <el-form ref="form1" :model="form1" label-width="80px">
                <el-form-item label="键盘颜色">
                    <el-input v-model="form1.keyboardcolorname"></el-input>
                </el-form-item>
                <el-button type="primary" @click="onsubmit">立即提交</el-button>
                <el-button @click="dialogVisible1=false">取消</el-button>
            </el-form>
            <span slot="footer" class="dialog-footer">
  </span>
        </el-dialog>

        <el-tab-pane label="轴体类型" name="second">
            <el-button type="success" @click="addshaftchoose" size="small">新增</el-button>
            <template>
                <el-table
                        :data="tableDate2"
                        style="width: 100%">
                    <el-table-column
                            prop="shaftchooseid"
                            label="ID"
                    >
                    </el-table-column>
                    <el-table-column
                            prop="shaftchoose"
                            label="轴体类型"
                    >
                    </el-table-column>
                    <el-table-column
                            fixed="right"
                            label="操作"
                    >
                        <template slot-scope="scope">
                            <el-button type="primary" @click="updateshaftchoose(scope.row)">编辑</el-button>
                            <el-button type="danger" @click="deleteshaftchoose(scope.row.shaftchooseid)">删除
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination
                        @size-change="handleSizeChange1"
                        @current-change="handleCurrentChange1"
                        :current-page="currentPage1"
                        :page-sizes="[1, 5, 10, 15]"
                        :page-size=pageSize1
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total1">
                </el-pagination>
            </template>
        </el-tab-pane>
        <%--            轴体类型新增的对话框--%>
        <el-dialog
                title="新增轴体类型"
                :visible.sync="dialogVisible2"
                width="30%"
                :before-close="handleClose2">

            <el-form ref="form2" :model="form2" label-width="80px">
                <el-form-item label="轴体类型">
                    <el-input v-model="form2.shaftchoose" placeholder="请输入轴体类型"></el-input>
                </el-form-item>
                <el-button type="primary" @click="onSubmit1">立即创建</el-button>
                <el-button @click="dialogVisible2=false">取消</el-button>
            </el-form>
            <span slot="footer" class="dialog-footer">
  </span>
        </el-dialog>
        <%--            轴体类型修改的对话框--%>
        <el-dialog
                title="修改轴体类型"
                :visible.sync="dialogVisible4"
                width="30%"
                :before-close="handleClose4">
            <el-form ref="form4" :model="form4" label-width="80px">
                <el-form-item label="轴体类型">
                    <el-input v-model="form4.shaftchoose"></el-input>
                </el-form-item>
                <el-button type="primary" @click="onsubmit1">立即提交</el-button>
                <el-button @click="dialogVisible4=false">取消</el-button>
            </el-form>
            <span slot="footer" class="dialog-footer">
  </span>
        </el-dialog>
        <el-tab-pane label="背光颜色" name="third">
            <el-button type="success" @click="addbacklightcolor" size="small">新增</el-button>
            <template>
                <el-table
                        :data="tableDate3"
                        style="width: 100%">
                    <el-table-column
                            prop="backlightcolorid"
                            label="ID"
                    >
                    </el-table-column>
                    <el-table-column
                            prop="backlightcolorname"
                            label="背光颜色"
                    >
                    </el-table-column>
                    <el-table-column
                            fixed="right"
                            label="操作"
                    >
                        <template slot-scope="scope">
                            <el-button type="primary" @click="updatebacklightcolor(scope.row)">编辑</el-button>
                            <el-button type="danger" @click="deletebacklightcolor(scope.row.backlightcolorid)">删除
                            </el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <el-pagination
                        @size-change="handleSizeChange2"
                        @current-change="handleCurrentChange2"
                        :current-page="currentPage2"
                        :page-sizes="[1, 5, 10, 15]"
                        :page-size=pageSize2
                        layout="total, sizes, prev, pager, next, jumper"
                        :total="total2">
                </el-pagination>
            </template>
            <%--            背光颜色新增的对话框--%>
            <el-dialog
                    title="新增背光颜色"
                    :visible.sync="dialogVisible3"
                    width="30%"
                    :before-close="handleClose3">

                <el-form ref="form3" :model="form3" label-width="80px">
                    <el-form-item label="背光颜色">
                        <el-input v-model="form3.backlightcolorname" placeholder="请输入背光颜色"></el-input>
                    </el-form-item>
                    <el-button type="primary" @click="onSubmit2">立即创建</el-button>
                    <el-button @click="dialogVisible3=false">取消</el-button>
                </el-form>
                <span slot="footer" class="dialog-footer">
  </span>
            </el-dialog>
            <%--            背光颜色修改的对话框--%>
            <el-dialog
                    title="修改背光颜色"
                    :visible.sync="dialogVisible5"
                    width="30%"
                    :before-close="handleClose5">
                <el-form ref="form5" :model="form5" label-width="80px">
                    <el-form-item label="轴体类型">
                        <el-input v-model="form5.backlightcolorname"></el-input>
                    </el-form-item>
                    <el-button type="primary" @click="onsubmit3">立即提交</el-button>
                    <el-button @click="dialogVisible5=false">取消</el-button>
                </el-form>
                <span slot="footer" class="dialog-footer">
  </span>
            </el-dialog>
        </el-tab-pane>
    </el-tabs>
</div>

</body>
<script>
    let app = new Vue({
        el: "#app",
        data: {
            activeName: 'first',
            tableDate1: [],
            tableDate2: [],
            tableDate3: [],
            formInline: {},
            //当前页码显示为1
            currentPage: 1,
            pageSize: 5,
            currentPage1: 1,
            pageSize1: 5,
            currentPage2: 1,
            pageSize2: 5,
            total: 1,
            total1: 1,
            total2: 1,
            form: {},
            form1: {},
            form2: {},
            form3: {},
            form4: {},
            form5: {},
            dialogVisible: false,
            dialogVisible1: false,
            dialogVisible2: false,
            dialogVisible3: false,
            dialogVisible4: false,
            dialogVisible5: false,

        },
        created() {
            this.inittable1()
            this.inittable2()
            this.inittable3()
        },
        methods: {
            //初始化键盘颜色表格
            inittable1() {
                axios.post("/goods/keyboardcolor?currentPage=" + this.currentPage + "&pageSize=" + this.pageSize, this.formInline).then(function (resp) {
                    app.tableDate1 = resp.data.data.list
                    app.total = resp.data.data.total
                })
            },
            //    初始化轴体类型
            inittable2() {
                axios.post("/goods/shaftchoose?currentPage=" + this.currentPage1 + "&pageSize=" + this.pageSize1).then(function (resp) {
                    app.tableDate2 = resp.data.data.list
                    app.total1 = resp.data.data.total
                })
            },
            //    初始化背光颜色
            inittable3() {
                axios.post("/goods/backlightcolor?currentPage=" + this.currentPage2 + "&pageSize=" + this.pageSize2).then(function (resp) {
                    app.tableDate3 = resp.data.data.list
                    app.total2 = resp.data.data.total
                })
            },
            //    根据条件搜索相应键盘颜色
            searchkeyboard(status) {
                if (status === 1) {
                    this.currentPage = 1;
                }
                app.inittable1();
            },
            //    改变页面大小的函数
            handleSizeChange(val) {
                this.pageSize = val;
                this.inittable1();
            },
            //    改变显示页码的函数
            handleCurrentChange(val) {
                this.currentPage = val;
                this.inittable1();
            },
            //    改变页面大小的函数
            handleSizeChange1(val) {
                this.pageSize1 = val;
                this.inittable2();
            },
            //    改变显示页码的函数
            handleCurrentChange1(val) {
                this.currentPage1 = val;
                this.inittable2();
            },
            //    改变页面大小的函数
            handleSizeChange2(val) {
                this.pageSize2 = val;
                this.inittable3();
            },
            //    改变显示页码的函数
            handleCurrentChange2(val) {
                this.currentPage2 = val;
                this.inittable3();
            },
            //    编辑键盘颜色
            updateKeyboardcolor(row) {
                this.dialogVisible1 = true;
                this.form1 = row;
            },
            //    编辑轴体类型
            updateshaftchoose(row) {
                this.dialogVisible4 = true;
                this.form4 = row;
            },
            //    编辑背光颜色
            updatebacklightcolor(row) {
                this.dialogVisible5 = true;
                this.form5 = row;
            },
            //    编辑键盘颜色确定按钮
            onsubmit() {
                axios.post("/goods/updatekeyboardcolor", this.form1).then(function (resp) {
                    if (resp.data === 1) {
                        //    刷新页面
                        app.inittable1();
                    }
                    app.dialogVisible1 = false;
                })
            },
            //    编辑轴体类型确定按钮
            onsubmit1() {
                axios.post("/goods/updateshaftchoose", this.form4).then(function (resp) {
                    if (resp.data === 1) {
                        //    刷新页面
                        app.inittable2();
                    }
                    app.dialogVisible4 = false;
                })
            },
            //    编辑背光颜色确定按钮
            onsubmit3() {
                axios.post("/goods/updatebacklightcolor", this.form5).then(function (resp) {
                    if (resp.data === 1) {
                        //    刷新页面
                        app.inittable3();
                    }
                    app.dialogVisible5 = false;
                })
            },
            //    删除键盘颜色
            deleteKeyboardcolor(keyboardcolorid) {
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get("/goods/keyboardcolordel?keyboardcolorid=" + keyboardcolorid).then(function (resp) {
                        var data = resp.data;
                        if (data === 1) {
                            app.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            app.inittable1()
                        }
                    })

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            // 删除轴体类型
            deleteshaftchoose(shaftchooseid) {
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get("/goods/shaftchoosedel?shaftchooseid=" + shaftchooseid).then(function (resp) {
                        var data = resp.data;
                        if (data === 1) {
                            app.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            app.inittable2()
                        }
                    })

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            // 删除背光颜色
            deletebacklightcolor(backlightcolorid) {
                this.$confirm('此操作将永久删除该文件, 是否继续?', '提示', {
                    confirmButtonText: '确定',
                    cancelButtonText: '取消',
                    type: 'warning'
                }).then(() => {
                    axios.get("/goods/deletebacklightcolor?backlightcolorid=" + backlightcolorid).then(function (resp) {
                        var data = resp.data;
                        if (data === 1) {
                            app.$message({
                                type: 'success',
                                message: '删除成功!'
                            });
                            app.inittable3()
                        }
                    })

                }).catch(() => {
                    this.$message({
                        type: 'info',
                        message: '已取消删除'
                    });
                });
            },
            //新增按钮
            addkeyboardcolor() {
                app.dialogVisible = true
            },
            addshaftchoose() {
                app.dialogVisible2 = true
            },
            addbacklightcolor() {
                app.dialogVisible3 = true
            },
            //添加颜色提交按钮
            onSubmit() {
                axios.post("/goods/addkeyboardcolor", this.form).then(function (resp) {
                    if (resp.data === 1) {
                        //    刷新页面
                        app.inittable1()
                    }
                    app.dialogVisible = false;
                })
            },
            //添加轴体类型提交按钮
            onSubmit1() {
                console.log(app.form2)
                axios.post("/goods/addshaftchoose", this.form2).then(function (resp) {

                    if (resp.data === 1) {
                        //    刷新页面
                        app.inittable2()
                    }
                    app.dialogVisible2 = false;
                })
            },
            //添加背光颜色提交按钮
            onSubmit2() {
                axios.post("/goods/addbacklightcolor", this.form3).then(function (resp) {
                    if (resp.data === 1) {
                        //    刷新页面
                        app.inittable3()
                    }
                    app.dialogVisible3 = false;
                })
            },
            //关闭页面
            handleClose(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            //关闭页面
            handleClose3(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            //关闭页面
            handleClose5(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            //关闭页面
            handleClose4(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            //关闭页面
            handleClose2(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },

            //关闭页面
            handleClose1(done) {
                this.$confirm('确认关闭？')
                    .then(_ => {
                        done();
                    })
                    .catch(_ => {
                    });
            },
            //


        }

    })
</script>
</html>
